package pack.help.realRobot.uC;
import pack.help.realRobot.Motor;
import pack.help.realRobot.Signal;
import pack.help.realRobot.SignalChange;

public class Port {

	private Signal value = Signal.LOW;
	
	private Signal prevValue = Signal.LOW;
	
	private SignalChange change = SignalChange.NOCHANGE;
	
	private Motor motor;
	
	public void setValue(Signal s){
		prevValue = value;
		value = s;
		
		if (prevValue == value){
			change = SignalChange.NOCHANGE;
		} else if (prevValue==Signal.HIGH && value == Signal.LOW){
			change = SignalChange.DESCEND;
			changed();
		} else {
			change = SignalChange.ASCEND;
			changed();
		}
	}
	
	public void invert(){
		if (value == Signal.LOW){
			setValue(Signal.HIGH);
		} else {
			setValue(Signal.LOW);
		}
	}
	
	private void changed(){
		/// TO DO ///
		motor.getClass();
		/// TO DO ///
	}
	
	public Signal getValue(){
		return value;	
	}
	
	public SignalChange getChange(){
		return change;
	}
	
	public Port(Motor m){
		motor = m;
	}
}
